import axios from 'axios';

const API_BASE_URL = '/api/admin';

// 获取会议室列表
export const getRooms = async () => {
  try {
    const response = await axios.get(`${API_BASE_URL}/rooms`);
    return response.data;
  } catch (error) {
    console.error('获取会议室列表失败', error);
    throw error;
  }
};

// 创建会议室
export const createRoom = async (roomData) => {
  try {
    const response = await axios.post(`${API_BASE_URL}/rooms`, roomData);
    return response.data;
  } catch (error) {
    console.error('创建会议室失败', error);
    throw error;
  }
};

// 更新会议室
export const updateRoom = async (roomData) => {
  try {
    const response = await axios.put(`${API_BASE_URL}/rooms/${roomData.id}`, roomData);
    return response.data;
  } catch (error) {
    console.error('更新会议室失败', error);
    throw error;
  }
};

// 删除会议室
export const deleteRoom = async (roomId) => {
  try {
    const response = await axios.delete(`${API_BASE_URL}/rooms/${roomId}`);
    return response.data;
  } catch (error) {
    console.error('删除会议室失败', error);
    throw error;
  }
};  